package com.chaochis.springboottestdemo.util;

import com.chaochis.springboottestdemo.enumList.DateFormat;

import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtil {

    public static String getFormatDate(Date date){
        return getFormateDate(date, "yyyy-MM-dd HH:mm:ss");
    }

    public static String getFormatDate(Date date, DateFormat dateFormat) {
        return getFormateDate(date, dateFormat.getFormat());
    }

    public static String getFormateDate(Date date, String dateFormat) {
        if (date == null) {
            return null;
        }
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormat);
        return simpleDateFormat.format(date);
    }
}
